﻿package com.wandian.util.word
{
	import ghostcat.util.core.Singleton;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class WordFilter extends Object
	{
		private var _arrReplace:Array;
		private var _nLength:int;
		private static var _instance:WordFilter=null;

		public function WordFilter(param1:Singleton)
		{
			if (param1 == null)
			{
				throw new Error("Can\'t create instance , Single is Null!");
			}
			this.init();
			return;
		} 

		private function init():void
		{
			var _loc_1:*=String("");
			_loc_1=_loc_1.replace(/\r""\r/g, "");
			this._arrReplace=_loc_1.split("、");
			return;
		} 

		public function filterMsg(param1:String):String
		{
			var _loc_2:RegExp=null;
			var _loc_3:int=0;
			while (_loc_3 < this._arrReplace.length)
			{

				_loc_2=new RegExp("(" + this._arrReplace[_loc_3] + ")", "gi");
				this._nLength=this._arrReplace[_loc_3].length;
				param1=param1.replace(_loc_2, this.replaceMsg);
				_loc_3=_loc_3 + 1;
			}
			return param1;
		} 

		private function replaceMsg(param1, param2, param3, param4):String
		{
			var _loc_5:String="";
			var _loc_6:int=0;
			while (_loc_6 < this._nLength)
			{

				_loc_5=_loc_5 + "*";
				_loc_6=_loc_6 + 1;
			}
			return _loc_5;
		} 

		public static function get instance():WordFilter
		{
			if (_instance == null)
			{
				_instance=new WordFilter(new Singleton());
			}
			return _instance;
		} 

	}
}
